import time
from threading import Thread


def func(name):
    time.sleep(2)
    print(f'任务[{name}]在执行')


if __name__ == '__main__':
    t = Thread(target=func, args=('发送邮件',))
    # 必须在t.start()之前设置
    t.daemon = True
    t.start()
    time.sleep(3)
